from concepts.attributes import Attribute, Object, _


class Process(Object):
    speed = Attribute()
    
    progress = Attribute(initial = 0, writable = True, initiable = False)
    
    @property
    def modifier(self):
        return 1
    
    def advance(self):
        self.progress += self.speed * self.modifier
        
        if self.progress >= 1:
            self.act(int(self.progress))
            self.progress -= int(self.progress)
    
    def act(self, num):
        pass


class CallbackProcess(Process):
    callback = Attribute()
    
    def act(self, num):
        self.callback(num)
